package com.chanzany.adapter.objectBased;

//适配器类
public class VoltageAdapter implements IVoltage5V {
    //关联关系---聚合
    private Voltage220V voltage220V;
    //构造器注入
    public VoltageAdapter(Voltage220V voltage220V) {
        this.voltage220V = voltage220V;
    }
    //setter注入
    public void setVoltage220V(Voltage220V voltage220V) {
        this.voltage220V = voltage220V;
    }

    @Override
    public int output5V() {
        //获取220V电压
        int src = voltage220V.output220V();
        //将220V降压到5V并返回
        int dst = src / 44;
        return dst;
    }
}
